package de.gameduell.framework.game.billard.view {
	import fl.transitions.easing.None;
	
	import de.gameduell.framework.game.billard.model.ShootData;
	import de.gameduell.framework.gui.animation.CombinedTween;
	import de.gameduell.framework.gui.animation.GDTween;
	import de.gameduell.framework.gui.animation.Tweenable;
	
	import org.cove.ape.Vector;	

	/**
	 * @author cbra
	 */
	public class ShootDataTween extends CombinedTween implements Tweenable {

		private static const DURATION:Number = 0.5;
		
		private var shootData:ShootData;
		private var direction:Vector;
		private var hitPoint:Vector;
		private var angle:Number;
		private var strength:Number;
		
		/**
		 * 	shootData.direction = new Vector(Number(event.parameters[0]),Number(event.parameters[1]));
			shootData.hitPoint 	= new Vector(Number(event.parameters[2]),Number(event.parameters[3]));
			shootData.angle		= Number(event.parameters[4]);
			shootData.strength  = Number(event.parameters[5]);
		 */
			
		public function ShootDataTween(aShootData:ShootData,aDirection:Vector,aHitPoint:Vector,aAngle:Number,aStrength:Number) {
			shootData = aShootData;
			direction = aDirection;
			hitPoint = aHitPoint;
			angle = aAngle;
			strength = aStrength;	
		}
		
		override public function start():void{
			if(!shootData.direction.equals(direction)){
				addTween(new GDTween(shootData,"directionX",None.easeNone,shootData.directionX,direction.x,DURATION,true));
				addTween(new GDTween(shootData,"directionY",None.easeNone,shootData.directionY,direction.y,DURATION,true));
			}
			if(!shootData.hitPoint.equals(hitPoint)){
				addTween(new GDTween(shootData,"hitPointX",None.easeNone,shootData.hitPointX,hitPoint.x,DURATION,true));
				addTween(new GDTween(shootData,"hitPointY",None.easeNone,shootData.hitPointY,hitPoint.y,DURATION,true));
			}
			if(shootData.angle != angle){
				addTween(new GDTween(shootData,"angle",None.easeNone,shootData.angle,angle,DURATION,true));
			}
			
			addTween(new GDTween(shootData,"strength",None.easeNone,shootData.strength,strength,DURATION,true));

			super.start();
		}

	}
}
